package com.ayq.activiti.manager.subscribe;

import com.ayq.activiti.manager.config.ActivitiRabbitMqConfig;
import com.ayq.activiti.manager.service.RabbitMqTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ActivitiNodeInfoUpdateSubscribe {

    @Autowired
    private RabbitMqTaskService rabbitMqTaskService;

    @RabbitListener(queues = ActivitiRabbitMqConfig.ACTIVITI_NODE_INFO_UPDATE_QUEUE)
    public void message(byte[] message) {
        try {
            rabbitMqTaskService.updateNodeInfo(new String(message));
        } catch (RuntimeException e) {
            e.printStackTrace();
            log.error("流程变更接收消息-任务处理失败", e);
        }
        log.info("流程变更接收消息{}", message);
    }
}
